package drds.common.db.xml_mapping.session;


import drds.common.db.xml_mapping.executor.BatchResult;

import java.io.Closeable;
import java.sql.Connection;
import java.util.List;
import java.util.Map;


public interface MapperContext extends Closeable {


  <T> T selectOne(String statement);

  <T> T selectOne(String statement, Object parameter);

  <E> List<E> selectList(String statement);


  <E> List<E> selectList(String statement, Object parameter);


  <E> List<E> selectList(String statement, Object parameter, RowBounds rowBounds);


  <K, V> Map<K, V> selectMap(String statement, String mapKey);

  <K, V> Map<K, V> selectMap(String statement, Object parameter, String mapKey);

  /**
   * The selectMap is a special case in that it is designed to convert a list
   * of results into a Map based on one of the properties in the resulting
   * objects.
   *
   * @param <K>       the returned Map keys parameter_and_result_value_type
   * @param <V>       the returned Map values parameter_and_result_value_type
   * @param statement Unique identifier matching the statement to use.
   * @param parameter A parameter object to pass to the statement.
   * @param mapKey    The property to use as key for each value in the list.
   * @param rowBounds Bounds to limit object retrieval
   * @return Map containing key pair data.
   */
  <K, V> Map<K, V> selectMap(String statement, Object parameter, String mapKey, RowBounds rowBounds);


  void select(String statement, Object parameter, ResultHandler handler);

  void select(String statement, ResultHandler handler);


  void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler);


  int insert(String statement);


  int insert(String statement, Object parameter);

  int update(String statement);

  int update(String statement, Object parameter);


  int delete(String statement);

  int delete(String statement, Object parameter);

  void commit();


  void commit(boolean force);

  void rollback();


  void rollback(boolean force);


  List<BatchResult> flushStatements();


  @Override
  void close();


  void clearCache();


  Configuration getConfiguration();


  <T> T getMapper(Class<T> type);


  Connection getConnection();
}
